package org.jeecg.modules.util;

import com.alibaba.excel.metadata.Sheet;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Administrator
 * @title: MyExcelUtil
 * @projectName jeecg-boot
 * @description: TODO
 * @date 2025/4/259:27
 */
@Component
@Slf4j
public class MyExcelUtil {


    public void doDetailExcel(){
        Sheet sheet = new Sheet(1, 4);
        List<Object> objects = ExcelUtil.readLessThan1000RowBySheet("brandFilePath", sheet);
        StringBuffer stringBuffer = new StringBuffer();
        boolean on = true;
        for (Object o : objects) {
            List<String> list = (ArrayList) o;
            if(StringUtils.isBlank(list.get(0))){
                continue;
            }
            if(list.get(0).startsWith("辅助核算")) {
                on = true;
                continue;
            }
            if(list.get(0).startsWith("操作人")) {
                on = false;
                continue;
            }
            if (on) {
                if (list.size()>=16 && ("EMS".equals(list.get(4))||"应付帐款".equals(list.get(4)))) {
                    log.info("...{}",list.get(0));
                    String sql = "insert into detail_info (detail_id,detail_name,source,debit,create_time) values('" + list.get(1) + "','" + list.get(2) + "','" + list.get(4) + "','" + list.get(9) + "','"+new Date() +"');\n";
                    stringBuffer.append(sql);
                }
            }
        }
    }
}
